Skip to main content

xDai Bridge

info

The xDAI bridge can be used in https://bridge.gnosischain.com by selecting DAI/xDAI.
Please avoid using the legacy xDai bridge: https://bridge.legacy.gnosischain.com/.

The xDai bridge is a native DAI bridge from Ethereum that is used to mint and burn xDai, the native asset used for gas and transaction fees on Gnosis.

Once Dai is bridged into the xDai bridge, the xDai bridge contract on Gnosis notifies the block rewards contract. The consensus algorithm then mints xDai to the user's corresponding address on Gnosis in the next block.

Key Information

Overview

Detail
Frontend URLhttps://bridge.gnosischain.com
Trust Model4-of-7 Validator Multisig
Governance8-of-16 Multisig
Governance ParametersValidator Set, Daily Limits, Fees
Bug BountyUp to $2m
Bug ReportingImmunefi

Key Contracts

Ethereum

ContractEthereum Address
xDAI Bridge Contracteth:0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016
Validator Management Contracteth:0xe1579dEbdD2DF16Ebdb9db8694391fa74EeA201E
info

The current deployment of xDAI bridge contract is from tokenbridge-contracts/xdaibridge-upgrade-sdai, with the commit hash bf602f35e624cc6c58c827e7c56b23c8b1afa69a

References:
** Some of the informations from TokenBridge Docs are outdated, please verify the information before you bridge.

Fees & Daily Limits

TypeEthereum -> GnosisGnosis -> Ethereum
Bridge Fees0%0%
Min Transfer0.005 Dai10 xDai
Daily Limit10,000,000 Dai10,000,000 xDai
Max Single Deposit9,999,999 Dai10,000,000 xDai
note

Daily Limit is reset according to the following logic: the smart contract stores total amount of processed tokens per current day and reverts on a new transfer if it exceeds the daily limit. Id of the day is calculated using the formula timestamp / (number of seconds in 1 day), where timestamp is the Unix timestamp.

Bridge Validators

Bridge Governance

How it Works

Ethereum -> Gnosis Chain.

The xDai token is minted when Dai is transferred from Ethereum to Gnosis using the xDai Bridge. During the transfer process, a block reward contract is invoked to mint xDai to a user's account. Because contract calls are made from the consensus engine to create xDai tokens, balance updates are more difficult to trace than simple value transfers.

  1. Users lock DAI on the bridge contract on Ethereum by approving the bridge contract and calling relayTokens.
  2. UserRequestForAffirmation event is triggered
  3. Validators observe the deposit and invoke executeAffirmation function on Gnosis bridge contract
  4. When enough confirmations are collected (4/7 majority), the bridge contract on Gnosis Chain calls the block reward contract to record the receiver(s) and amount(s) of xDAI to mint.
  5. The block reward contract is called by the consensus engine to update user's xDAI balance.

User may check the balance change visually using Blockscout's coin balance history or programmatically using eth_getBalance API.

You can also view a receiver's address and amount of xDai received in the block reward contract's logs. Whenever the executeAffirmation method is called, it emits the AddedReceiver event:

AddedReceiver(
uint256 amount,
address indexed receiver,
address indexed bridge
)

Example: https://gnosis.blockscout.com/tx/0x5892a695860f6087a2d93140f05e6365142ff77fd7128e39dbc03128d5797ac4?tab=logs


Gnosis Chain -> Ethereum.

  1. User transfer xDAI to Gnosis Chain's xDAI bridge, xDAI is burned.
  2. UserRequestForSignature event emitted (see example transaction).
  3. Validators listen to the event and call submitSignature on Gnosis chain.
  4. After enough signatures are collected, CollectedSignatures event is emitted
  5. Anyone can execute the withdrawal on Ethereum (user via UI or validator). DAI is unlocked to the receiver on Ethereum.
  6. RelayedMessage emitted on mainnet
note

This final step may be delayed if Ethereum mainnet is congested.

References:

Savings xDAI

Application: https://agave.finance/sdai/

Rationale

MakerDAO’s DSR current rate is 5%. Since the increase of the DSR to ~3.5%, ~7M DAI have fled out of the xDAI bridge, as can be seen on this dashboard. Bridging the DSR yield into Gnosis Chain will help regain these deposits. In order to provide the needed catalyst for Gnosis Chain Defi to boom, interest rates on Gnosis Chain have to pick up or reach parity with Ethereum or other chains with higher borrowing demand.

Introducing Savings DAI (sDAI), a DSR(Dai Savings Rate) module in xDAI Bridge between Ethereum and Gnosis Chain.

By depositing most of the DAI in xDAI bridge into sDAI vault from Spark Protocol on Ethereum, which is a ERC4626 vault depositing all DAI into the Maker DSR, interest is accrued from Maker DSR and relayed to Gnosis Chain. xDAI holders on Gnosis Chain can mint sDAI with their xDAI, and enjoy the interest accumulating from Ethereum.

Check out the proposal from Karpatkey to Deposit DAI of the xDAI bridge in sDAI vault from Spark

Interest rate

Assuming the amount of “Savings DAI on GC” minted is lower than the one held by the bridge, then the yield will be higher than the Dai savings Rate. The bridge currently holds roughly 25M DAI and the DSR yield is 5%, assuming 25M get wrapped into sDAI and only 10M xDAI get deposited into the vault on GC, the yield will be 12.5% .

The expectation is that the sDAI rate will always be higher on GC than Mainnet, as only if almost 100% of all DAI bridged is staked will we achieve rate parity.

Considering the current 25M DAI sitting in the bridge, that represents ~1.25M yearly to incentivise GC.

DSR yield is risk-free if you are already holding DAI. All the risks derived from the collateral are borne by all DAI holders, regardless of them depositing in the DSR. Karpatkey team have written a research piece here. The only newly introduced risk is smart contract risk in how the integration is made with the sDAI vault on Ethereum and the implementation of the sDAI vault on GC.

Architecture

Ethereum

A new implementation upgrade in xDAIForeignBridge contract: SavingsDAI Connector is added as a dependency in the contract. Compare to the old implementation of the Compound Connector, the payInterest function in SavingsDai Connector is used to transfer interest received from vault to receiver address on Gnosis Chain rather than to receiver address on Ethereum.

sDAI is deployed on Ethereum. Any future DAI deposited to the Bridge will be wrapped into sDAI, with caveat that it will always keep the buffer of the minimumCashThreshold when investing.

minimumCashThreshold: This value determines what is the recommended amount of DAI that should be held in the bridge at all times, in order to create a buffer for withdrawals without added operations and thus lower gas costs.

Gnosis Chain

There are two contracts being deployed on Gnosis.

The first one is the sDAI vault, also an ERC 4626 which is the most popular standard for vaults which makes it extremely useful for Defi integrations from Lending Protocols like Agave and Spark,  to DEXes like Curve and Balancer with their boosted pools. The only modification to the standard vault (OZ implementation) is that it will allow for direct deposits and withdrawals in xDAI, rather than exclusively the ERC20 WXDAI.

The second contract is the Interest Receiver. This will be the address provided on Mainnet bridge as the interest receiver. What this contract does is quite simple, it distributes the balance it holds in xDAI and WXDAI into sDAI at a fixed block rate that gets updated every 1-2 days to adjust for interest rate changes coming from mainnet. The goal of this contract is to not make it possible to front run the bridging process of the interest, and to make sure there is a fairly frequent update of the sDAI shares value and exchange rate. This contract has the perk of being very easy to switch for a different one by simply setting a new receiver on the bridge, without impacting any of the operations. This means if we want to make modifications such as add a fee or normalize rates in the future, that will be very easy to plug-in.

Role and responsibilities

xDAI/wxDAI holder

  1. Deposit xDAI/wxDAI and get sDAI shares:
    1. xDAI/wxDAI holders can deposit xDAI/wxDAI in https://agave.finance/sdai/, in return for sDAI, and their corresponding shares in the vault are recorded.
    2. Bridge Interest Receiver receives interest from mainnet and distribute to sDAI vault.
    3. sDAI holders withdraw/redeem xDAI/wxDAI (interest+original amount) according to their shares, that has gone up because of the interest received in step 2

Keeper

  1. Call investDAI() refillBridge() payInterest(). On Ethereum, anyone is allowed to investDAI() into the sDAI vault, anyone is allowed to refillBridge() right back up to the threshold, and also anyone is allowed to payInterest(). These processes are permissionless, and it’s also costly which is why we will have a bot to automate these 3 maintenance procedures in the most efficient way possible.
  2. Keeper is maintained by Karpatkey team. Source Code

Contracts

Resources